#include <QCoreApplication>
#include "demothread.h"
#include "demo.h"
#include <iostream>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    DemoThread t;
    t.start();

    Demo d;
    QThread th;
    d.moveToThread(&th);
    QObject::connect(&th, &QThread::started, &d, &Demo::start);
//    QObject::connect(&th, &QThread::finished, &d, &Demo::deleteLater);
#if 0
    QObject::connect(&d, &Demo::end, &th, &QThread::quit);
#else
    QObject::connect(&d, &Demo::end, [&]() {
       th.quit();
    });
#endif

    std::cout << "adadsda" << std::endl;
    th.start();
    th.wait();

    std::cout << "end" << std::endl;

    return a.exec();
}
